

// const http = require('http')
// const server = http.createServer((req,res)=>{
//    console.log(`请求过来了${req.url}`);
//    if(req.url === '/'){

//    }else if(req.url === '/abc'){

//    }else if(req.url === '/abc/ddd/eee'){

//    }
// })

// server.listen(3000,()=>{
//     console.log(`server is runnig...`);
// })


const express = require('express')
const path = require('path')
// app application 
const app = express()
// 处理静态资源
// app.use(express.static(path.join(__dirname,'./public')))
app.use(express.static(path.join(__dirname,'./public')))


app.get('/',(req,res)=>{
    console.log(`express 请求路径${req.url}`);
    console.log(req);
    res.send('你好')
})

app.get('/abc/ddd',(req,res)=>{
    console.log(`express 请求路径${req.url}`);
    res.send('请求结束')
})
app.get('/user/login',(req,res)=>{
    console.log(req.hostname);
    console.log(req.originalUrl)
    console.log(req.url);
    console.log(req.params);
    console.log(req.path);
    console.log(req.body);
    res.send(req.query)
})

app.get('/abc/ddd/eee',(req,res)=>{
    res.redirect('http://www.baidu.com')
})

app.post('/abc',(req,res)=>{
    res.send('post 请求')
})
app.listen(3000,()=>{
    console.log(`server is running...port is 3000`);
})



